﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
//using CDSBDemandControl.Model;

namespace CDSBDemandControl.Presenter
{
    public class XMLDemandManager
    {
        public string XmlPath { get; set; }
        public Encoding EncodingType { get; set; }
                
        public XMLDemandManager(string xmlPath, Encoding encodingType)
        {
            this.XmlPath = xmlPath;
            this.EncodingType = encodingType;
            //XmlTextWriter myXmlTextWriter = new XmlTextWriter("newbooks.xml", System.Text.Encoding.UTF8);
        }

        //public void CreateXMLDemands(IEnumerable<Model.DemandModel> demandModels)
        //{
        //    XmlTextWriter myXmlTextWriter = new XmlTextWriter(XmlPath, EncodingType);

        //    myXmlTextWriter.Formatting = System.Xml.Formatting.Indented;

        //    myXmlTextWriter.WriteStartDocument(false);

        //    myXmlTextWriter.WriteStartElement("WorkItemCollection");

        //    foreach (DemandModel Demand in demandModels)
        //    {
        //        myXmlTextWriter.WriteStartElement("WorkItem");

        //        myXmlTextWriter.WriteStartElement("ID");
        //        myXmlTextWriter.WriteString(Demand.ID);
        //        myXmlTextWriter.WriteEndElement();

        //        myXmlTextWriter.WriteStartElement("Title");
        //        myXmlTextWriter.WriteString(Demand.Title);
        //        myXmlTextWriter.WriteEndElement();

        //        myXmlTextWriter.WriteStartElement("CreatedBy");
        //        myXmlTextWriter.WriteString(Demand.CreatedBy);
        //        myXmlTextWriter.WriteEndElement();

        //        myXmlTextWriter.WriteStartElement("AssignedTo");
        //        myXmlTextWriter.WriteString(Demand.AssignedTo);
        //        myXmlTextWriter.WriteEndElement();

        //        myXmlTextWriter.WriteStartElement("Project");
        //        myXmlTextWriter.WriteString(Demand.Project);
        //        myXmlTextWriter.WriteEndElement();

        //        myXmlTextWriter.WriteStartElement("Responsible");
        //        myXmlTextWriter.WriteString(Demand.Responsible);
        //        myXmlTextWriter.WriteEndElement();

        //        myXmlTextWriter.WriteStartElement("Conclude");
        //        myXmlTextWriter.WriteString(Demand.Conclude.HasValue ? Demand.Conclude.ToString() : "");
        //        myXmlTextWriter.WriteEndElement();

        //        myXmlTextWriter.WriteStartElement("ActiveControlUrL");
        //        myXmlTextWriter.WriteString(Demand.ActiveControlUrL);
        //        myXmlTextWriter.WriteEndElement();

        //        myXmlTextWriter.WriteStartElement("Reason");
        //        myXmlTextWriter.WriteString(Demand.Reason);
        //        myXmlTextWriter.WriteEndElement();

        //        myXmlTextWriter.WriteStartElement("EstimatedConclude");
        //        myXmlTextWriter.WriteString(Demand.EstimatedConclude.HasValue ? Demand.EstimatedConclude.ToString(): "");
        //        myXmlTextWriter.WriteEndElement();

        //        myXmlTextWriter.WriteStartElement("EstimatedHours");
        //        myXmlTextWriter.WriteString(Demand.EstimatedHours);
        //        myXmlTextWriter.WriteEndElement();

        //        myXmlTextWriter.WriteStartElement("EstimatedStart");
        //        myXmlTextWriter.WriteString(Demand.EstimatedStart.HasValue ? Demand.EstimatedStart.ToString() : "");
        //        myXmlTextWriter.WriteEndElement();

        //        myXmlTextWriter.WriteStartElement("Start");
        //        myXmlTextWriter.WriteString(Demand.Start.HasValue ? Demand.Start.ToString() : "");
        //        myXmlTextWriter.WriteEndElement();

        //        //myXmlTextWriter.WriteStartElement("StatusColor");
        //        //myXmlTextWriter.WriteString(Demand.StatusColor);
        //        //myXmlTextWriter.WriteEndElement();

        //        myXmlTextWriter.WriteStartElement("title");
        //        myXmlTextWriter.WriteString(Demand.WorkItemType);
        //        myXmlTextWriter.WriteEndElement();

        //        myXmlTextWriter.WriteEndElement();
        //    }

        //    myXmlTextWriter.WriteEndElement();

        //    myXmlTextWriter.Flush();

        //    myXmlTextWriter.Close();

        //}
    }
}
